/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tpgen.manchester.oppl;

import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author shanki
 */
@Deprecated
public class ForbiddenConstructs {
    private static final Construct[] some  = new Construct[] {
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf
    };
    
    private static final Construct[] only   = new Construct[] {
        Construct.objectRestriction_only,
        Construct.dataRestriction_only,
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.objectRestriction_exactly,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf        
    };
    
    private static final Construct[] value   = new Construct[] {
        Construct.objectRestriction_value,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf        
    };
    
    private static final Construct[] min   = new Construct[] {
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf
    };
    
    private static final Construct[] exactly   = new Construct[] {
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf        
    };
    
    private static final Construct[] max   = new Construct[] {
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf
    };
    
    private static final Construct[] not   = new Construct[] {
        Construct.classNot,
        Construct.negativeDataPropertyAssertionAxiom,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_only,
        Construct.dataRestriction_only,
        Construct.objectRestriction_value,
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.classUnion,
        Construct.classIntersection,
        Construct.oneOf        
    };    

    private static final Construct[] oneOf   = new Construct[] {
        Construct.oneOf,
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_only,
        Construct.dataRestriction_only,
        Construct.objectRestriction_value,
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.classIntersection,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,    
    };
    
    private static final Construct[] classUnion   = new Construct[] {
        Construct.classUnion,
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_only,
        Construct.dataRestriction_only,
        Construct.objectRestriction_value,
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.classIntersection,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
    };
    
    private static final Construct[] classIntersection   = new Construct[] {
        Construct.classIntersection,
        Construct.objectRestriction_some,
        Construct.dataRestriction_some,
        Construct.objectRestriction_only,
        Construct.dataRestriction_only,
        Construct.objectRestriction_value,
        Construct.objectRestriction_min,
        Construct.dataRestriction_min,
        Construct.objectRestriction_exactly,
        Construct.dataRestriction_exactly,
        Construct.objectRestriction_max,
        Construct.dataRestriction_max,
        Construct.classUnion,
        Construct.classNot,
        Construct.negativeObjectPropertyAssertionAxiom,
        Construct.negativeDataPropertyAssertionAxiom,
    };  
    
    private static final Map<Construct, Construct[]> forbidden;


    
    static {
        forbidden   = new EnumMap<Construct, Construct[]>(Construct.class);
        forbidden.put(Construct.objectRestriction_some, some);
        forbidden.put(Construct.dataRestriction_some, some);
        forbidden.put(Construct.objectRestriction_max, max);
        forbidden.put(Construct.dataRestriction_max, max);
        forbidden.put(Construct.objectRestriction_min, min);
        forbidden.put(Construct.dataRestriction_min, min);
        forbidden.put(Construct.objectRestriction_exactly, exactly);
        forbidden.put(Construct.dataRestriction_exactly, exactly);
        forbidden.put(Construct.classNot, not);
        forbidden.put(Construct.negativeObjectPropertyAssertionAxiom, not);
        forbidden.put(Construct.negativeDataPropertyAssertionAxiom, not);
        forbidden.put(Construct.classUnion, classUnion);
        forbidden.put(Construct.classIntersection, classIntersection);
        forbidden.put(Construct.oneOf, oneOf);
        forbidden.put(Construct.objectRestriction_only, only);
        forbidden.put(Construct.dataRestriction_only, only);
        forbidden.put(Construct.objectRestriction_value, value);
    }
    
    public static Set<Construct> expand(Iterable<Construct> forbiddenConstructs) {
        Set<Construct> all    = new HashSet<Construct>();
        
        for (Construct construct : forbiddenConstructs) {
            all.addAll(expand(construct));
        }
        
        return all;
    }
    
    public static Collection<? extends Construct> expand(Construct construct) {
        Set<Construct> all    = new HashSet<Construct>();
        all.add(construct);
        
        if (forbidden.containsKey(construct)) {        
            all.addAll(Arrays.asList(forbidden.get(construct)));
        }
        
        return all;
    }    
}
